package com.rockcent.mall.lib.repository;

import com.rockcent.common.common.PageResult;
import com.rockcent.mall.lib.domain.enumclass.*;
import com.rockcent.mall.lib.dto.ChannelDto;
import com.rockcent.mall.lib.dto.ChannelStatisticsChartDto;
import com.rockcent.mall.lib.dto.MerchantChannelStatisticsDto;
import com.rockcent.mall.lib.dto.ProductStatisticsDto;

import java.math.BigDecimal;
import java.util.List;

/**
 * Created by windy on 16-11-1.
 */
public interface MerchantChannelStatisticsRepositoryCustom {

    PageResult<MerchantChannelStatisticsDto> getChannelStatisticsInfo(PageResult page, Long mallId, Long merchantId);

    Long getChannelProductCategoryCount(Long channelId, Long mallId, Long merchantId);

    PageResult<ProductStatisticsDto> getChannelProductStatisticsDetails(Long channelId, Long id, Long id1, String type, MerchantOrderSourceType sourceType, String startDate, String endDate, String productName, PageResult pageResult);

    List<ChannelStatisticsChartDto> genarateCustomerCountChartByCondition(String startDate, String endDate, Long mallId, Long merchantId, StatististicsType type);

    List<ChannelStatisticsChartDto> genarateViewCountChartByCondition(String startDate, String endDate, Long mallId, Long merchantId, StatististicsType type);

    List<ChannelStatisticsChartDto> genarateSaleCountChartByCondition(String startDate, String endDate, Long mallId, Long merchantId, StatististicsType type);

    List<ChannelStatisticsChartDto> genarateSaleCustomerCountChartByCondition(String startDate, String endDate, Long mallId, Long merchantId, StatististicsType type);

    List<ChannelStatisticsChartDto> genarateSaleRateChartByCondition(String startDate, String endDate, Long mallId, Long merchantId, StatististicsType type);

    List<ChannelStatisticsChartDto>  genarateVerificationRateChartByCondition(String startDate, String endDate, Long mallId, Long merchantId, StatististicsType yesterday);

    List<ChannelStatisticsChartDto> genarateVerificationCustomerCountChartByCondition(String startDate, String endDate, Long mallId, Long merchantId, StatististicsType yesterday);

    List<ChannelStatisticsChartDto>  genarateVerificationCountChartByCondition(String startDate, String endDate, Long mallId, Long merchantId, StatististicsType yesterday);

    Long getProductViewCustomerCount(Long productId, Long channelId, String sourceType, String type,Long mallId,Long merchantId, String startDate, String endDate);

    Long getProductViewCount(Long productId, Long channelId, String sourceType, String type,Long mallId,Long merchantId, String startDate, String endDate);

    Long getProductSaleCount(Long productId, Long channelId, String sourceType, String type,Long mallId,Long merchantId, String startDate, String endDate);

    Long getProductOrderCustomerCount(Long productId, Long channelId, String sourceType, String type,Long mallId,Long merchantId, String startDate, String endDate);

    Long getProductVerifyCount(Long productId, Long channelId, String sourceType, String type,Long mallId,Long merchantId, String startDate, String endDate);

    Long getProductVerifyCustomerCount(Long productId, Long channelId, String sourceType, String type,Long mallId,Long merchantId, String startDate, String endDate);
    
    Long getOrderTotalByProductIdAndMallIdAndMerchantId(Long productId, String sourceType, String type, Long id, Long id1, String startDate, String endDate);

    Long getVerificationTotalByProductIdAndMallIdAndMerchantId(Long productId, String sourceType, String type, Long id, Long id1, String startDate, String endDate);

    Long getViewCountByChannelId(Long channelId, Long mallId, Long merchantId, String type, Long typeId, MerchantOrderSourceType merchantOrderSourceType, String startDate, String endDate);

    Double queryProductPriceByProductIdAndMallIdAndMerchantId(Long productId, Long channelId, String sourceType, String type, Long mallId, Long merchantId, String startDate, String endDate);

    public Long getOrderCountByChannelId(Long channelId, Long mallId, String type, Long merchantId,Long typeId,StatististicsType statististicsType,  String orderSourceType, String startDate, String endDate);

    /**
     * 访问次数
     * @param mallId
     * @param merchantId
     * @param startDate
     * @param endDate
     * @param typeIds
     * @param sourceType
     * @return
     */
    Long channelViewCount(Long mallId, Long merchantId, String startDate, String endDate, List<Long> typeIds, String sourceType, Long channelId);

    /**
     * 访问次数 top 10
     * @param mallId
     * @param merchantId
     * @param startDate
     * @param endDate
     * @param typeIds
     * @param sourceType
     * @param groupBy
     * @param channelIds
     * @return
     */
    List<ChannelStatisticsChartDto> channelViewCount(Long mallId, Long merchantId, String startDate, String endDate, List<Long> typeIds, String sourceType, String groupBy, List<Long> channelIds);

    /**
     * 访问人数
     * @param mallId
     * @param merchantId
     * @param startDate
     * @param endDate
     * @param typeIds
     * @param sourceType
     * @return
     */
    Long channelViewCustomerCount(Long mallId, Long merchantId, String startDate, String endDate, List<Long> typeIds, String sourceType, Long channelId);

    /**
     * 访问人数 top 10
     * @param mallId
     * @param merchantId
     * @param startDate
     * @param endDate
     * @param typeIds
     * @param sourceType
     * @param groupBy
     * @param channelIds
     * @return
     */
    List<ChannelStatisticsChartDto> channelViewCustomerCount(Long mallId, Long merchantId, String startDate, String endDate, List<Long> typeIds, String sourceType, String groupBy, List<Long> channelIds);

    /**
     * 销售数量
     * @param mallId
     * @param merchantId
     * @param startDate
     * @param endDate
     * @param typeIds
     * @param sourceType
     * @return
     */
    Long channelSaleCount(Long mallId, Long merchantId, String startDate, String endDate, List<Long> typeIds, String sourceType, Long channelId);

    /**
     * 销售数量 top 10
     * @param mallId
     * @param merchantId
     * @param startDate
     * @param endDate
     * @param typeIds
     * @param sourceType
     * @param groupBy
     * @param channelIds
     * @return
     */
    List<ChannelStatisticsChartDto> channelSaleCount(Long mallId, Long merchantId, String startDate, String endDate, List<Long> typeIds, String sourceType, String groupBy, List<Long> channelIds);

    /**
     * 下单人数
     * @param mallId
     * @param merchantId
     * @param startDate
     * @param endDate
     * @param typeIds
     * @param sourceType
     * @return
     */
    Long channelOrderCustomerCount(Long mallId, Long merchantId, String startDate, String endDate, List<Long> typeIds, String sourceType, Long channelId);

    /**
     * 下单人数 top 10
     * @param mallId
     * @param merchantId
     * @param startDate
     * @param endDate
     * @param typeIds
     * @param sourceType
     * @param groupBy
     * @param channelIds
     * @return
     */
    List<ChannelStatisticsChartDto> channelOrderCustomerCount(Long mallId, Long merchantId, String startDate, String endDate, List<Long> typeIds, String sourceType, String groupBy, List<Long> channelIds);

    /**
     * 核销数量
     * @param mallId
     * @param merchantId
     * @param startDate
     * @param endDate
     * @param typeIds
     * @param sourceType
     * @return
     */
    Long channelVerifyCount(Long mallId, Long merchantId, String startDate, String endDate, List<Long> typeIds, String sourceType, Long channelId);

    /**
     * 核销数量 top 10
     * @param mallId
     * @param merchantId
     * @param startDate
     * @param endDate
     * @param typeIds
     * @param sourceType
     * @param groupBy
     * @param channelIds
     * @return
     */
    List<ChannelStatisticsChartDto> channelVerifyCount(Long mallId, Long merchantId, String startDate, String endDate, List<Long> typeIds, String sourceType, String groupBy, List<Long> channelIds);

    /**
     * 核销人数
     * @param mallId
     * @param merchantId
     * @param startDate
     * @param endDate
     * @param typeIds
     * @param sourceType
     * @return
     */
    Long channelVerifyCustomerCount(Long mallId, Long merchantId, String startDate, String endDate, List<Long> typeIds, String sourceType, Long channelId);

    /**
     * 核销人数 top 10
     * @param mallId
     * @param merchantId
     * @param startDate
     * @param endDate
     * @param typeIds
     * @param sourceType
     * @param groupBy
     * @param channelIds
     * @return
     */
    List<ChannelStatisticsChartDto> channelVerifyCustomerCount(Long mallId, Long merchantId, String startDate, String endDate, List<Long> typeIds, String sourceType, String groupBy, List<Long> channelIds);

    /**
     * 查找渠道列表
     * @param page
     * @param mallId
     * @param merchantId
     * @param startDate
     * @param endDate
     * @param typeIds
     * @param sourceType
     * @param channelIds
     * @return
     */
    PageResult<ChannelStatisticsChartDto> findChannels(PageResult page, Long mallId, Long merchantId, String startDate, String endDate, List<Long> typeIds, String sourceType, List<Long> channelIds);

    /**
     * 查找渠道下产品品类
     * @param mallId
     * @param merchantId
     * @param channelId
     * @return
     */
    List<ChannelStatisticsChartDto> findChannelProductCategories(Long mallId, Long merchantId, Long channelId);

    /**
     * 计算各渠道的访问量与销售量
     * @param page
     * @param mallId
     * @param merchantId
     * @return
     */
    PageResult<ChannelDto> calculateChannelsViewCountAndSaleCount(PageResult page, Long mallId, Long merchantId);
}
